/**********************************************************************************************/
// dgt_BoolConverter.h
//
// Common Lib for Digital Studio
// Block of management of bool functions
// Main class, that represent converter of bool functions
//
// Copyright Diamant Group 2008
/**********************************************************************************************/
#ifndef _DGT_BOOLCONVERTER_H_
#define _DGT_BOOLCONVERTER_H_

#include "dgtKernel.h"
#include "dgt_SmartMacros.h"
#include "dgt_BoolFunction.h"
#include "dgt_BoolElement.h"
#include "dgt_LogicTable.h"

SMART_CLASS( dgt_BoolConverter );

/**********************************************************************************************/
/**
* \brief Main class of block of management of bool functions.
*/
class dgt_BoolConverter
{
	public://///////////////////////////////////////////////////////////////////////////////////

		/**
		* @brief Ctor - receives on an input logic table of converting bool function
		* @param inTable logic table
		*/
		dgt_BoolConverter( dgt_LogicTable_Ptr inTable );

		/**
		* @brief Dtor as default
		*/
virtual						~dgt_BoolConverter()							{};

	public://///////////////////////////////////////////////////////////////////////////////////

		/**
		* @brief Function for getting main normal form ( AND/OR ) of bool function
		* @param inAndInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inAndInputs) is a maximum count of inputs, not exact quantity
		* @param inOrInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inOrInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form AND/OR of bool function
		*/
		dgt_BoolFunction_Ptr	get_MainForm(short	inAndInputs = 0,
											short	inOrInputs = 0 );

		/**
		* @brief Function for getting normal form ( NOTAND/NOTAND ) of bool function
		* @param inNotAndInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotAndInputs) is a maximum count of inputs, not exact quantity
		* @return Normal form NOTAND/NOTAND of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_NOTAND(short	inNotAndInputs = 0 );

		/**
		* @brief Function for getting normal form ( OR/NOTAND ) of bool function
		* @param inOrInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inOrInputs) is a maximum count of inputs, not exact quantity
		* @param inNotAndInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotAndInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form OR/NOTAND of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_ORNOTAND(	short	inOrInputs = 0,
													short	inNotAndInputs = 0 );

		/**
		* @brief Function for getting normal form ( NOTOR/OR ) of bool function
		* @param inNotOrInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotOrInputs) is a maximum count of inputs, not exact quantity
		* @param inOrInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inOrInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form NOTOR/OR of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_NOTOROR(	short	inNotOrInputs = 0,
													short	inOrInputs = 0 );

		/**
		* @brief Function for getting normal form ( AND/NOTOR ) of bool function
		* @param inAndInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inAndInputs) is a maximum count of inputs, not exact quantity
		* @param inNotOrInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotOrInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form AND/NOTOR of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_ANDNOTOR(	short	inAndInputs = 0,
													short	inNotOrInputs = 0 );

		/**
		* @brief Function for getting normal form ( NOTAND/AND ) of bool function
		* @param inNotAndInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotAndInputs) is a maximum count of inputs, not exact quantity
		* @param inAndInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inAndInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form NOTAND/AND of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_NOTANDAND(	short	inNotAndInputs = 0,
													short	inAndInputs = 0 );

		/**
		* @brief Function for getting normal form ( OR/AND ) of bool function
		* @param inOrInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inOrInputs) is a maximum count of inputs, not exact quantity
		* @param inAndInputs Count of inputs of OR gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inAndInputs ) is a maximum count of inputs, not exact quantity
		* @return Normal form OR/AND of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_ORAND(	short	inOrInputs = 0,
												short	inAndInputs = 0 );

		/**
		* @brief Function for getting normal form ( NOTOR/NOTOR ) of bool function
		* @param inNotOrInputs Count of inputs of AND gates 
		*		 if 0 - there are no restrictions
		*		 if <0 - abs( inNotOrInputs) is a maximum count of inputs, not exact quantity
		* @return Normal form NOTOR/NOTOR of bool function
		*/
		dgt_BoolFunction_Ptr	get_Form_NOTOR(	short	inNotOrInputs = 0 );

		/**
		* @brief Function for minimization of main normal form (AND/OR) of bool function
		*		 Before calling this function must be called get_MainForm for construct main form.
		*		 Otherwise it will return NULL.
		*		 This function will overwrite AND/OR normal form of function by minimized function.
		* @return Minimized normal form AND/OR of bool function
		*/
		dgt_BoolFunction_Ptr	Minimize( void );

		/**
		* @brief Function for factorization of main normal form (AND/OR) of bool function
		*		 Before calling this function must be called get_MainForm for construct main form.
		*		 Otherwise it will return NULL.
		* @return Factorized normal form AND/OR of bool function
		*/
		dgt_BoolFunction_Ptr	Factorize( void );


	private:////////////////////////////////////////////////////////////////////////////////////

		dgt_LogicTable_Ptr		m_LogicTable;		/*!< Logic table of bool function */
	
		dgt_BoolFunction_Ptr	m_MainForm;			/*!< Main form of bool function (AND/OR) */
	
		dgt_BoolFunction_Ptr	m_FormNOTAND;		/*!< Form of bool function (NOTAND/NOTAND) */

		dgt_BoolFunction_Ptr	m_FormORNOTAND;		/*!< Form of bool function (OR/NOTAND) */

		dgt_BoolFunction_Ptr	m_FormNOTOROR;		/*!< Form of bool function (NOTOR/OR) */

		dgt_BoolFunction_Ptr	m_FormANDNOTOR;		/*!< Form of bool function (AND/NOTOR) */

		dgt_BoolFunction_Ptr	m_FormNOTANDAND;	/*!< Form of bool function (NOTAND/AND) */

		dgt_BoolFunction_Ptr	m_FormORAND;		/*!< Form of bool function (OR/AND) */

		dgt_BoolFunction_Ptr	m_FormNOTOR;		/*!< Form of bool function (NOTOR/NOTOR) */
		
};

#endif // _DGT_BOOLCONVERTER_H_
